package com.dommettj.rawfix.matchers;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

public class FixMessageTypeMatcher extends TypeSafeMatcher<String> {

    private final String expectedMessageType;

    public static FixMessageTypeMatcher messageType(final String messageType) {
        return new FixMessageTypeMatcher(messageType);
    }

    private FixMessageTypeMatcher(final String messageType) {
        this.expectedMessageType = messageType;
    }

    @Override
    protected boolean matchesSafely(final String message) {
        return message.contains("35=" + expectedMessageType);
    }

    @Override
    public void describeTo(Description description) {
        description.appendValue("Fix Message of type [" + expectedMessageType + "]");
    }
}
